import java.util.Random;

// 使用类来表示一个算式结构
class ArithmeticProblem {
    int operand1;
    int operand2;
    char operator;

    // 构造函数
    public ArithmeticProblem(int operand1, int operand2, char operator) {
        this.operand1 = operand1;
        this.operand2 = operand2;
        this.operator = operator;
    }

    // 显示算式的方法
    public void displayProblem() {
        System.out.printf("%d %c %d = \n", operand1, operator, operand2);
    }

    // 重写toString方法，方便输出
    @Override
    public String toString() {
        return operand1 + " " + operator + " " + operand2 + " = ";
    }
}

public class Calculation_SystemV1 {
    public static void main(String[] args) {
        Random random = new Random();

        System.out.println("欢迎使用加减法口算练习系统！");
        System.out.println("以下是50道100以内的加减法算式：");
        System.out.println("==============================");

        // 生成50道算式
        for (int i = 1; i <= 50; i++) {
            // 生成两个0-100之间的随机数
            int num1 = random.nextInt(101);
            int num2 = random.nextInt(101);

            // 随机决定是加法还是减法（0表示加法，1表示减法）
            int operation = random.nextInt(2);
            char operator = (operation == 0) ? '+' : '-';

            // 创建算式对象
            ArithmeticProblem problem = new ArithmeticProblem(num1, num2, operator);

            // 输出算式（不计算结果）
            System.out.printf("第%2d题: %s\n", i, problem.toString());
        }

        System.out.println("==============================");
        System.out.println("练习题生成完毕！");
    }
}
